<html>
<head><meta charset="utf-8"><title>How long until a const generic can depend on another gene... · project-const-generics · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/index.html">project-const-generics</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html">How long until a const generic can depend on another gene...</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="245894090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245894090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245894090">(Jul 13 2021 at 21:49)</a>:</h4>
<p>Hello. I have two very similar types:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">VolBlockIter</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">R</span><span class="p">,</span><span class="w"> </span><span class="n">W</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="k">pub</span><span class="p">(</span><span class="k">crate</span><span class="p">)</span><span class="w"> </span><span class="n">base</span>: <span class="nc">VolAddress</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">R</span><span class="p">,</span><span class="w"> </span><span class="n">W</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">  </span><span class="k">pub</span><span class="p">(</span><span class="k">crate</span><span class="p">)</span><span class="w"> </span><span class="n">count</span>: <span class="kt">usize</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">VolSeriesIter</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">R</span><span class="p">,</span><span class="w"> </span><span class="n">W</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">S</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="k">pub</span><span class="p">(</span><span class="k">crate</span><span class="p">)</span><span class="w"> </span><span class="n">base</span>: <span class="nc">VolAddress</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">R</span><span class="p">,</span><span class="w"> </span><span class="n">W</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">  </span><span class="k">pub</span><span class="p">(</span><span class="k">crate</span><span class="p">)</span><span class="w"> </span><span class="n">count</span>: <span class="kt">usize</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>And I would like to collapse them down so that there's just one struct, the second one with the const generic, and things that currently return the first struct can automatically fill in <code>S</code> with <code>size_of::&lt;T&gt;()</code>.</p>
<p>rustc says I cannot do this, and doesn't even suggest a nightly feature for how to enable this. Is it actually a close sort of development that might exist by the end of the year? or is it one of those very tricky projects that will take a multi-stage effort to complete?</p>



<a name="245894159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245894159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245894159">(Jul 13 2021 at 21:49)</a>:</h4>
<p>that sounds like you might want <code>const_generics_defaults</code> ?</p>



<a name="245894182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245894182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245894182">(Jul 13 2021 at 21:50)</a>:</h4>
<p><code>struct Foo&lt;T, const N: usize = { std::mem::size_of::&lt;T&gt;() }&gt;</code> ?</p>



<a name="245897117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245897117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245897117">(Jul 13 2021 at 22:21)</a>:</h4>
<p>hm, okay, so I can set a default using that, <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=65801fc9c0b9046b4598a3c31a3e095c">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=65801fc9c0b9046b4598a3c31a3e095c</a></p>
<p>so now I need to ask about the simplicity/timeline of both <code>const_generics_defaults</code> and apparently also <code>const_evaluable_checked</code>.</p>
<p>Can there perhaps be a <code>min_const_evaluable_checked</code> for the operations that trivially never fail to evaluate? Eg: size_of, align_of, bitand, bitor, bitxor.</p>



<a name="245897214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245897214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245897214">(Jul 13 2021 at 22:22)</a>:</h4>
<p>const_generics_defaults its basically completed impl wise and is pretty close to stabilisation (imo)</p>



<a name="245897277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245897277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245897277">(Jul 13 2021 at 22:23)</a>:</h4>
<p>const_evaluatable_checked is far far off ^^'</p>



<a name="245897293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245897293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245897293">(Jul 13 2021 at 22:23)</a>:</h4>
<p>yeah it seems to be the forever lurking demon</p>



<a name="245897463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245897463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245897463">(Jul 13 2021 at 22:25)</a>:</h4>
<p>im not sure about the idea of <code>min_const_evaluatable_checked</code>i feel Like there's probably corners we can cut for defaults that that never fail to evaluate</p>



<a name="245897609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245897609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245897609">(Jul 13 2021 at 22:27)</a>:</h4>
<p>just from an ergonomics-using-const_evaluatable_checked perspective</p>



<a name="245897616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245897616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245897616">(Jul 13 2021 at 22:27)</a>:</h4>
<p>it seems nice to allow those things without an evaluatable bound</p>



<a name="245897719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245897719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245897719">(Jul 13 2021 at 22:28)</a>:</h4>
<p>there's problems with const_evaluatable_checked though that arent solved by only permitting expressions that cant fail to evaluate</p>



<a name="245897736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245897736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245897736">(Jul 13 2021 at 22:29)</a>:</h4>
<p>afaik most (all?) are not problems for using complex expression in cg defaults</p>



<a name="245897777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245897777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245897777">(Jul 13 2021 at 22:29)</a>:</h4>
<p>im ramblign a bit at this point :)</p>



<a name="245897925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245897925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245897925">(Jul 13 2021 at 22:31)</a>:</h4>
<p>i expect we can support the use case of <code>const N: usize = { std::mem::size_of::&lt;T&gt;() }</code> without requiring evaluatable bounds long before const_evalautable_checked is stabilised</p>



<a name="245897938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245897938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245897938">(Jul 13 2021 at 22:31)</a>:</h4>
<p>it seems technically feasible at the very least ^^</p>



<a name="245897969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245897969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245897969">(Jul 13 2021 at 22:31)</a>:</h4>
<p>right now cgdefaults + const evaluatable checked isnt super usable though</p>



<a name="245898040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245898040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245898040">(Jul 13 2021 at 22:32)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=a5876e6cc2c14868756ccef1cbff788d">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=a5876e6cc2c14868756ccef1cbff788d</a></p>



<a name="245898050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245898050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245898050">(Jul 13 2021 at 22:32)</a>:</h4>
<p>actually have the defaults be you know... used like a default</p>



<a name="245898052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245898052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245898052">(Jul 13 2021 at 22:32)</a>:</h4>
<p>causes an ice</p>



<a name="245898058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245898058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245898058">(Jul 13 2021 at 22:32)</a>:</h4>
<p>(there's a PR open to fix it)</p>



<a name="245898087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245898087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245898087">(Jul 13 2021 at 22:33)</a>:</h4>
<p>Sound distant enough that I should send out the 1.0 of this crate now and then do a 2.0 some day in the future if anyone even cares about collapsing the two iterator types together (maybe no one really cares about merging the two types).</p>



<a name="245898111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/How%20long%20until%20a%20const%20generic%20can%20depend%20on%20another%20gene.../near/245898111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/How.20long.20until.20a.20const.20generic.20can.20depend.20on.20another.20gene.2E.2E.2E.html#245898111">(Jul 13 2021 at 22:33)</a>:</h4>
<p>^^</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>